#!/bin/bash
# vim:  fdm=marker fmr=[[[,]]] cms=\ #%s#

SEND()
{ #[[[#
    read -p "mail: " mail
    $CLIENT $ADDR SEND "$mail" "zhou_arron@163.com" "zhou_arron@163.com" "测试" "$BODY"
} #]]]#

SENDVIP()
{ #[[[#
    read -p "mail: " mail
    $CLIENT $ADDR SENDVIP "$mail" "zhou_arron@163.com" "zhou_arron@163.com" "测试VIP" "$BODY"
} #]]]#

bin_path=$(dirname $0)
if [ ${bin_path:0:1} != '/' ]
then
    bin_path=$(pwd)/$bin_path
fi
CLIENT=$bin_path/../../tool/snclient
ADDR=localhost:10040
BODY=

main()
{ #[[[#
    if [ ! -x "$CLIENT" ]
    then
        echo "snclient not found"
        return 1
    fi

    BODY=$(cat body.html)

    local option
    read -p "\
1) SEND
2) SENDVIP
Input: " option
    if [[ -z $option ]]
    then
        echo  "Error: input null"
        return 1
    fi
    case $option in
        1) SEND ;;
        2) SENDVIP ;;
        *)
            echo "Error: option($option) not supported"
            return 1
            ;;
    esac
} #]]]#

main
exit $?
